﻿<!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->

<UserControl
  xmlns="http://schemas.microsoft.com/client/2007"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:controls="clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls"
  x:Class="Microsoft.Windows.Controls.Samples.ViewboxSample">
    <StackPanel>
        <StackPanel.Resources>
            <Style x:Key="DemoButton" TargetType="Button">
                <Setter Property="Margin" Value="2" />
                <Setter Property="Content" Value="Content" />
            </Style>
        </StackPanel.Resources>

        <!-- Stretch table -->
        <ContentControl Content="Stretch" Style="{StaticResource Header}" />
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="150" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="150" />
            </Grid.ColumnDefinitions>
            
            <TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource Description}" Text="Stretch.None" />
            <TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource Description}" Text="Stretch.Fill" />
            <TextBlock Grid.Row="0" Grid.Column="2" Style="{StaticResource Description}" Text="Stretch.Uniform" FontWeight="Bold" />
            <TextBlock Grid.Row="0" Grid.Column="3" Style="{StaticResource Description}" Text="Stretch.UniformToFill" />
            
            <controls:Viewbox Grid.Row="1" Grid.Column="0" Stretch="None">
                <Button Style="{StaticResource DemoButton}" />
            </controls:Viewbox>
            <controls:Viewbox Grid.Row="1" Grid.Column="1" Stretch="Fill">
                <Button Style="{StaticResource DemoButton}" />
            </controls:Viewbox>
            <controls:Viewbox Grid.Row="1" Grid.Column="2" Stretch="Uniform">
                <Button Style="{StaticResource DemoButton}" />
            </controls:Viewbox>
            <controls:Viewbox Grid.Row="1" Grid.Column="3" Stretch="UniformToFill">
                <Button Style="{StaticResource DemoButton}" />
            </controls:Viewbox>
        </Grid>

        <!-- StretchDirection table -->
        <ContentControl Content="StretchDirection" Style="{StaticResource Header}" />
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="15" />
                <RowDefinition Height="150" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="150" />
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource Description}" Text="StretchDirection.UpOnly" />
            <TextBlock Grid.Row="0" Grid.Column="2" Style="{StaticResource Description}" Text="StretchDirection.DownOnly" />
            <TextBlock Grid.Row="0" Grid.Column="3" Style="{StaticResource Description}" Text="StretchDirection.Both" FontWeight="Bold" />
            
            <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource Description}" Text="Smaller" />
            <TextBlock Grid.Row="2" Grid.Column="0" Style="{StaticResource Description}" Text="Bigger" />
            
            <controls:Viewbox Grid.Row="1" Grid.Column="1" StretchDirection="UpOnly">
                <Button Style="{StaticResource DemoButton}" />
            </controls:Viewbox>
            <controls:Viewbox Grid.Row="1" Grid.Column="2" StretchDirection="DownOnly">
                <Button Style="{StaticResource DemoButton}" />
            </controls:Viewbox>
            <controls:Viewbox Grid.Row="1" Grid.Column="3" StretchDirection="Both">
                <Button Style="{StaticResource DemoButton}" />
            </controls:Viewbox>
            
            <controls:Viewbox Grid.Row="2" Grid.Column="1" StretchDirection="UpOnly">
                <Button Style="{StaticResource DemoButton}" />
            </controls:Viewbox>
            <controls:Viewbox Grid.Row="2" Grid.Column="2" StretchDirection="DownOnly">
                <Button Style="{StaticResource DemoButton}" />
            </controls:Viewbox>
            <controls:Viewbox Grid.Row="2" Grid.Column="3" StretchDirection="Both">
                <Button Style="{StaticResource DemoButton}" />
            </controls:Viewbox>
        </Grid>
        
        <!-- Child -->
        <ContentControl Content="Child" Style="{StaticResource Header}" />
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="150" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="150" />
            </Grid.ColumnDefinitions>
            
            <TextBlock Style="{StaticResource Description}" Text="Path" />
            <controls:Viewbox Grid.Row="1" Margin="2">
                <Path Stroke="#ff000000" StrokeThickness="8" Fill="#00ffff00" Width="200" Height="200"
                  Data="M95,0 L120,66 L190,69 L135,113 L154,181 L95,142 L36,181 L55,113 L0,69 L70,66 Z"/>
            </controls:Viewbox>

            <TextBlock Grid.Column="1" Style="{StaticResource Description}" Text="TextBlock" />
            <controls:Viewbox Grid.Row="1" Grid.Column="1" Margin="2">
                <TextBlock Text="TextBlock"/>
            </controls:Viewbox>

            <TextBlock Grid.Column="2" Style="{StaticResource Description}" Text="Image" />
            <controls:Viewbox Grid.Row="1" Grid.Column="2" Margin="2">
                <Image Source="/Silverlight.png"/>
            </controls:Viewbox>

            <TextBlock Grid.Column="3" Style="{StaticResource Description}" Text="ScrollView" />
            <controls:Viewbox Grid.Row="1" Grid.Column="3" Margin="2">
                <ScrollViewer>
                    <Image Source="/Silverlight.png"/>
                </ScrollViewer>
            </controls:Viewbox>

            <TextBlock Grid.Column="4" Style="{StaticResource Description}" Text="StackPanel" />
            <controls:Viewbox Grid.Row="1" Grid.Column="4" Margin="2">
                <StackPanel>
                    <Button Content="Button" FontSize="40"/>
                    <Image Source="/Silverlight.png"/>
                </StackPanel>
            </controls:Viewbox>
        </Grid>

        <!-- Interactive example -->
        <ContentControl Content="Interactive" Style="{StaticResource Header}" />
        <Grid Margin="2">
            <Grid.Resources>
                <Style x:Key="InteractionSlider" TargetType="Slider">
                    <Setter Property="Minimum" Value="0" />
                    <Setter Property="Maximum" Value="100" />
                    <Setter Property="Value" Value="100" />
                </Style>
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition Height="200" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Rectangle x:Name="InteractiveHeightIndicator" HorizontalAlignment="Stretch" VerticalAlignment="Top" Fill="#44FF0000" />
            <Rectangle x:Name="InteractiveWidthIndicator" HorizontalAlignment="Left" VerticalAlignment="Stretch" Fill="#44FF0000" />
            <Grid x:Name="InteractiveContainer">
                <controls:Viewbox x:Name="InteractiveViewbox" HorizontalAlignment="Left" VerticalAlignment="Top">
                    <Button Style="{StaticResource DemoButton}" />
                </controls:Viewbox>
            </Grid>
            <Slider x:Name="InteractiveVerticalSlider" Grid.Row="0" Grid.Column="1" Orientation="Vertical" Minimum="0" Maximum="100" Value="100" LargeChange="5" IsDirectionReversed="True" />
            <Slider x:Name="InteractiveHorizontalSlider" Grid.Row="1" Grid.Column="0" Orientation="Horizontal" Minimum="0" Maximum="100" Value="100" LargeChange="5" />
            <StackPanel Grid.Row="0" Grid.Column="2" Grid.RowSpan="2">
                <StackPanel.Resources>
                    <Style x:Key="StretchRadio" TargetType="RadioButton">
                        <Setter Property="GroupName" Value="Stretch" />
                        <Setter Property="Margin" Value="10 0 0 0" />
                        <Setter Property="FontSize" Value="10" />
                    </Style>
                    <Style x:Key="StretchDirectionRadio" TargetType="RadioButton">
                        <Setter Property="GroupName" Value="StretchDirection" />
                        <Setter Property="Margin" Value="10 0 0 0" />
                        <Setter Property="FontSize" Value="10" />
                    </Style>
                </StackPanel.Resources>
                
                <TextBlock Style="{StaticResource Description}" Text="Stretch" HorizontalAlignment="Left" TextDecorations="Underline" />
                <RadioButton x:Name="StretchNone" Style="{StaticResource StretchRadio}" Content="None"  />
                <RadioButton x:Name="StretchFill" Style="{StaticResource StretchRadio}" Content="Fill" />
                <RadioButton x:Name="StretchUniform" Style="{StaticResource StretchRadio}" Content="Uniform" IsChecked="true" />
                <RadioButton x:Name="StretchUniformToFill" Style="{StaticResource StretchRadio}" Content="UniformToFill" />
                
                <TextBlock Style="{StaticResource Description}" Text="StretchDirection" Margin="0 20 0 0" HorizontalAlignment="Left" TextDecorations="Underline" />
                <RadioButton x:Name="StretchDirectionUpOnly" Style="{StaticResource StretchDirectionRadio}" Content="UpOnly" />
                <RadioButton x:Name="StretchDirectionDownOnly" Style="{StaticResource StretchDirectionRadio}" Content="DownOnly" />
                <RadioButton x:Name="StretchDirectionBoth" Style="{StaticResource StretchDirectionRadio}" Content="Both" IsChecked="true" />
            </StackPanel>
        </Grid>
        <src:SourceViewer xmlns:src="clr-namespace:Microsoft.Windows.Controls.Samples;assembly=Microsoft.Windows.Controls.Samples.Common" xmlns:sys="clr-namespace:System;assembly=mscorlib">
  <src:SourceFile Path="ViewboxSample.xaml">
    <src:SourceFile.Source>
      <sys:String>&lt;!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
--&gt;

&lt;UserControl
  xmlns="http://schemas.microsoft.com/client/2007"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:controls="clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls"
  x:Class="Microsoft.Windows.Controls.Samples.ViewboxSample"&gt;
    &lt;StackPanel&gt;
        &lt;StackPanel.Resources&gt;
            &lt;Style x:Key="DemoButton" TargetType="Button"&gt;
                &lt;Setter Property="Margin" Value="2" /&gt;
                &lt;Setter Property="Content" Value="Content" /&gt;
            &lt;/Style&gt;
        &lt;/StackPanel.Resources&gt;

        &lt;!-- Stretch table --&gt;
        &lt;ContentControl Content="Stretch" Style="{StaticResource Header}" /&gt;
        &lt;Grid&gt;
            &lt;Grid.RowDefinitions&gt;
                &lt;RowDefinition Height="Auto" /&gt;
                &lt;RowDefinition Height="150" /&gt;
            &lt;/Grid.RowDefinitions&gt;
            &lt;Grid.ColumnDefinitions&gt;
                &lt;ColumnDefinition Width="150" /&gt;
                &lt;ColumnDefinition Width="150" /&gt;
                &lt;ColumnDefinition Width="150" /&gt;
                &lt;ColumnDefinition Width="150" /&gt;
            &lt;/Grid.ColumnDefinitions&gt;
            
            &lt;TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource Description}" Text="Stretch.None" /&gt;
            &lt;TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource Description}" Text="Stretch.Fill" /&gt;
            &lt;TextBlock Grid.Row="0" Grid.Column="2" Style="{StaticResource Description}" Text="Stretch.Uniform" FontWeight="Bold" /&gt;
            &lt;TextBlock Grid.Row="0" Grid.Column="3" Style="{StaticResource Description}" Text="Stretch.UniformToFill" /&gt;
            
            &lt;controls:Viewbox Grid.Row="1" Grid.Column="0" Stretch="None"&gt;
                &lt;Button Style="{StaticResource DemoButton}" /&gt;
            &lt;/controls:Viewbox&gt;
            &lt;controls:Viewbox Grid.Row="1" Grid.Column="1" Stretch="Fill"&gt;
                &lt;Button Style="{StaticResource DemoButton}" /&gt;
            &lt;/controls:Viewbox&gt;
            &lt;controls:Viewbox Grid.Row="1" Grid.Column="2" Stretch="Uniform"&gt;
                &lt;Button Style="{StaticResource DemoButton}" /&gt;
            &lt;/controls:Viewbox&gt;
            &lt;controls:Viewbox Grid.Row="1" Grid.Column="3" Stretch="UniformToFill"&gt;
                &lt;Button Style="{StaticResource DemoButton}" /&gt;
            &lt;/controls:Viewbox&gt;
        &lt;/Grid&gt;

        &lt;!-- StretchDirection table --&gt;
        &lt;ContentControl Content="StretchDirection" Style="{StaticResource Header}" /&gt;
        &lt;Grid&gt;
            &lt;Grid.RowDefinitions&gt;
                &lt;RowDefinition Height="Auto" /&gt;
                &lt;RowDefinition Height="15" /&gt;
                &lt;RowDefinition Height="150" /&gt;
            &lt;/Grid.RowDefinitions&gt;
            &lt;Grid.ColumnDefinitions&gt;
                &lt;ColumnDefinition Width="Auto" /&gt;
                &lt;ColumnDefinition Width="150" /&gt;
                &lt;ColumnDefinition Width="150" /&gt;
                &lt;ColumnDefinition Width="150" /&gt;
            &lt;/Grid.ColumnDefinitions&gt;

            &lt;TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource Description}" Text="StretchDirection.UpOnly" /&gt;
            &lt;TextBlock Grid.Row="0" Grid.Column="2" Style="{StaticResource Description}" Text="StretchDirection.DownOnly" /&gt;
            &lt;TextBlock Grid.Row="0" Grid.Column="3" Style="{StaticResource Description}" Text="StretchDirection.Both" FontWeight="Bold" /&gt;
            
            &lt;TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource Description}" Text="Smaller" /&gt;
            &lt;TextBlock Grid.Row="2" Grid.Column="0" Style="{StaticResource Description}" Text="Bigger" /&gt;
            
            &lt;controls:Viewbox Grid.Row="1" Grid.Column="1" StretchDirection="UpOnly"&gt;
                &lt;Button Style="{StaticResource DemoButton}" /&gt;
            &lt;/controls:Viewbox&gt;
            &lt;controls:Viewbox Grid.Row="1" Grid.Column="2" StretchDirection="DownOnly"&gt;
                &lt;Button Style="{StaticResource DemoButton}" /&gt;
            &lt;/controls:Viewbox&gt;
            &lt;controls:Viewbox Grid.Row="1" Grid.Column="3" StretchDirection="Both"&gt;
                &lt;Button Style="{StaticResource DemoButton}" /&gt;
            &lt;/controls:Viewbox&gt;
            
            &lt;controls:Viewbox Grid.Row="2" Grid.Column="1" StretchDirection="UpOnly"&gt;
                &lt;Button Style="{StaticResource DemoButton}" /&gt;
            &lt;/controls:Viewbox&gt;
            &lt;controls:Viewbox Grid.Row="2" Grid.Column="2" StretchDirection="DownOnly"&gt;
                &lt;Button Style="{StaticResource DemoButton}" /&gt;
            &lt;/controls:Viewbox&gt;
            &lt;controls:Viewbox Grid.Row="2" Grid.Column="3" StretchDirection="Both"&gt;
                &lt;Button Style="{StaticResource DemoButton}" /&gt;
            &lt;/controls:Viewbox&gt;
        &lt;/Grid&gt;
        
        &lt;!-- Child --&gt;
        &lt;ContentControl Content="Child" Style="{StaticResource Header}" /&gt;
        &lt;Grid&gt;
            &lt;Grid.RowDefinitions&gt;
                &lt;RowDefinition Height="Auto" /&gt;
                &lt;RowDefinition Height="150" /&gt;
            &lt;/Grid.RowDefinitions&gt;
            &lt;Grid.ColumnDefinitions&gt;
                &lt;ColumnDefinition Width="150" /&gt;
                &lt;ColumnDefinition Width="150" /&gt;
                &lt;ColumnDefinition Width="150" /&gt;
                &lt;ColumnDefinition Width="150" /&gt;
                &lt;ColumnDefinition Width="150" /&gt;
            &lt;/Grid.ColumnDefinitions&gt;
            
            &lt;TextBlock Style="{StaticResource Description}" Text="Path" /&gt;
            &lt;controls:Viewbox Grid.Row="1" Margin="2"&gt;
                &lt;Path Stroke="#ff000000" StrokeThickness="8" Fill="#00ffff00" Width="200" Height="200"
                  Data="M95,0 L120,66 L190,69 L135,113 L154,181 L95,142 L36,181 L55,113 L0,69 L70,66 Z"/&gt;
            &lt;/controls:Viewbox&gt;

            &lt;TextBlock Grid.Column="1" Style="{StaticResource Description}" Text="TextBlock" /&gt;
            &lt;controls:Viewbox Grid.Row="1" Grid.Column="1" Margin="2"&gt;
                &lt;TextBlock Text="TextBlock"/&gt;
            &lt;/controls:Viewbox&gt;

            &lt;TextBlock Grid.Column="2" Style="{StaticResource Description}" Text="Image" /&gt;
            &lt;controls:Viewbox Grid.Row="1" Grid.Column="2" Margin="2"&gt;
                &lt;Image Source="/Silverlight.png"/&gt;
            &lt;/controls:Viewbox&gt;

            &lt;TextBlock Grid.Column="3" Style="{StaticResource Description}" Text="ScrollView" /&gt;
            &lt;controls:Viewbox Grid.Row="1" Grid.Column="3" Margin="2"&gt;
                &lt;ScrollViewer&gt;
                    &lt;Image Source="/Silverlight.png"/&gt;
                &lt;/ScrollViewer&gt;
            &lt;/controls:Viewbox&gt;

            &lt;TextBlock Grid.Column="4" Style="{StaticResource Description}" Text="StackPanel" /&gt;
            &lt;controls:Viewbox Grid.Row="1" Grid.Column="4" Margin="2"&gt;
                &lt;StackPanel&gt;
                    &lt;Button Content="Button" FontSize="40"/&gt;
                    &lt;Image Source="/Silverlight.png"/&gt;
                &lt;/StackPanel&gt;
            &lt;/controls:Viewbox&gt;
        &lt;/Grid&gt;

        &lt;!-- Interactive example --&gt;
        &lt;ContentControl Content="Interactive" Style="{StaticResource Header}" /&gt;
        &lt;Grid Margin="2"&gt;
            &lt;Grid.Resources&gt;
                &lt;Style x:Key="InteractionSlider" TargetType="Slider"&gt;
                    &lt;Setter Property="Minimum" Value="0" /&gt;
                    &lt;Setter Property="Maximum" Value="100" /&gt;
                    &lt;Setter Property="Value" Value="100" /&gt;
                &lt;/Style&gt;
            &lt;/Grid.Resources&gt;
            &lt;Grid.RowDefinitions&gt;
                &lt;RowDefinition Height="200" /&gt;
                &lt;RowDefinition Height="Auto" /&gt;
            &lt;/Grid.RowDefinitions&gt;
            &lt;Grid.ColumnDefinitions&gt;
                &lt;ColumnDefinition Width="200" /&gt;
                &lt;ColumnDefinition Width="Auto" /&gt;
                &lt;ColumnDefinition Width="Auto" /&gt;
            &lt;/Grid.ColumnDefinitions&gt;

            &lt;Rectangle x:Name="InteractiveHeightIndicator" HorizontalAlignment="Stretch" VerticalAlignment="Top" Fill="#44FF0000" /&gt;
            &lt;Rectangle x:Name="InteractiveWidthIndicator" HorizontalAlignment="Left" VerticalAlignment="Stretch" Fill="#44FF0000" /&gt;
            &lt;Grid x:Name="InteractiveContainer"&gt;
                &lt;controls:Viewbox x:Name="InteractiveViewbox" HorizontalAlignment="Left" VerticalAlignment="Top"&gt;
                    &lt;Button Style="{StaticResource DemoButton}" /&gt;
                &lt;/controls:Viewbox&gt;
            &lt;/Grid&gt;
            &lt;Slider x:Name="InteractiveVerticalSlider" Grid.Row="0" Grid.Column="1" Orientation="Vertical" Minimum="0" Maximum="100" Value="100" LargeChange="5" IsDirectionReversed="True" /&gt;
            &lt;Slider x:Name="InteractiveHorizontalSlider" Grid.Row="1" Grid.Column="0" Orientation="Horizontal" Minimum="0" Maximum="100" Value="100" LargeChange="5" /&gt;
            &lt;StackPanel Grid.Row="0" Grid.Column="2" Grid.RowSpan="2"&gt;
                &lt;StackPanel.Resources&gt;
                    &lt;Style x:Key="StretchRadio" TargetType="RadioButton"&gt;
                        &lt;Setter Property="GroupName" Value="Stretch" /&gt;
                        &lt;Setter Property="Margin" Value="10 0 0 0" /&gt;
                        &lt;Setter Property="FontSize" Value="10" /&gt;
                    &lt;/Style&gt;
                    &lt;Style x:Key="StretchDirectionRadio" TargetType="RadioButton"&gt;
                        &lt;Setter Property="GroupName" Value="StretchDirection" /&gt;
                        &lt;Setter Property="Margin" Value="10 0 0 0" /&gt;
                        &lt;Setter Property="FontSize" Value="10" /&gt;
                    &lt;/Style&gt;
                &lt;/StackPanel.Resources&gt;
                
                &lt;TextBlock Style="{StaticResource Description}" Text="Stretch" HorizontalAlignment="Left" TextDecorations="Underline" /&gt;
                &lt;RadioButton x:Name="StretchNone" Style="{StaticResource StretchRadio}" Content="None"  /&gt;
                &lt;RadioButton x:Name="StretchFill" Style="{StaticResource StretchRadio}" Content="Fill" /&gt;
                &lt;RadioButton x:Name="StretchUniform" Style="{StaticResource StretchRadio}" Content="Uniform" IsChecked="true" /&gt;
                &lt;RadioButton x:Name="StretchUniformToFill" Style="{StaticResource StretchRadio}" Content="UniformToFill" /&gt;
                
                &lt;TextBlock Style="{StaticResource Description}" Text="StretchDirection" Margin="0 20 0 0" HorizontalAlignment="Left" TextDecorations="Underline" /&gt;
                &lt;RadioButton x:Name="StretchDirectionUpOnly" Style="{StaticResource StretchDirectionRadio}" Content="UpOnly" /&gt;
                &lt;RadioButton x:Name="StretchDirectionDownOnly" Style="{StaticResource StretchDirectionRadio}" Content="DownOnly" /&gt;
                &lt;RadioButton x:Name="StretchDirectionBoth" Style="{StaticResource StretchDirectionRadio}" Content="Both" IsChecked="true" /&gt;
            &lt;/StackPanel&gt;
        &lt;/Grid&gt;
    &lt;/StackPanel&gt;
&lt;/UserControl&gt;</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
  <src:SourceFile Path="ViewboxSample.xaml.cs">
    <src:SourceFile.Source>
      <sys:String>// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.

using System;
using System.Diagnostics.CodeAnalysis;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.ComponentModel;

namespace Microsoft.Windows.Controls.Samples
{
    /// &lt;summary&gt;
    /// Sample page demonstrating the Viewbox.
    /// &lt;/summary&gt;
    [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Viewbox", Justification = "Name of the control")]
    [Sample("Viewbox", DifficultyLevel.Basic)]
    [Category("ViewBox")]
    public partial class ViewboxSample : UserControl
    {
        /// &lt;summary&gt;
        /// Initializes a new instance of the ViewboxSample class.
        /// &lt;/summary&gt;
        public ViewboxSample()
        {
            InitializeComponent();

            // Add event handlers to update the interactive demo
            InteractiveHorizontalSlider.ValueChanged += (s, e) =&gt; UpdateInteractiveDemo();
            InteractiveVerticalSlider.ValueChanged += (s, e) =&gt; UpdateInteractiveDemo();
            StretchNone.Checked += (s, e) =&gt; UpdateInteractiveDemo();
            StretchFill.Checked += (s, e) =&gt; UpdateInteractiveDemo();
            StretchUniform.Checked += (s, e) =&gt; UpdateInteractiveDemo();
            StretchUniformToFill.Checked += (s, e) =&gt; UpdateInteractiveDemo();
            StretchDirectionUpOnly.Checked += (s, e) =&gt; UpdateInteractiveDemo();
            StretchDirectionDownOnly.Checked += (s, e) =&gt; UpdateInteractiveDemo();
            StretchDirectionBoth.Checked += (s, e) =&gt; UpdateInteractiveDemo();
        }

        /// &lt;summary&gt;
        /// Update the interactive Viewbox demo when any property changes.
        /// &lt;/summary&gt;
        private void UpdateInteractiveDemo()
        {
            InteractiveWidthIndicator.Width = InteractiveViewbox.Width = InteractiveContainer.ActualWidth * InteractiveHorizontalSlider.Value / 100.0;
            InteractiveHeightIndicator.Height = InteractiveViewbox.Height = InteractiveContainer.ActualHeight * InteractiveVerticalSlider.Value / 100.0;
            InteractiveViewbox.Stretch =
                (StretchFill.IsChecked == true) ? Stretch.Fill :
                (StretchUniform.IsChecked == true) ? Stretch.Uniform :
                (StretchUniformToFill.IsChecked == true) ? Stretch.UniformToFill :
                Stretch.None;
            InteractiveViewbox.StretchDirection =
                (StretchDirectionUpOnly.IsChecked == true) ? StretchDirection.UpOnly :
                (StretchDirectionDownOnly.IsChecked == true) ? StretchDirection.DownOnly :
                StretchDirection.Both;
        }
    }
}</sys:String>
    </src:SourceFile.Source>
  </src:SourceFile>
</src:SourceViewer>
    </StackPanel>
</UserControl>